// import axios from 'axios'

const getProjectBaseInfo = async () => {
    return await new Promise((resolve, reject) => {
        axios.get('/index/project/getProjectBaseInfo').then(res => {
            resolve(res.data.data)
        }).catch(err => {
            reject(err)
        })
    })
}

const saveProjectBaseInfo = async (params) => {
    return await new Promise((resolve, reject) => {
        axios.post('/index/project/saveProjectBaseInfo', params).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}

const getProjectChildrenList = async () => {
    return await new Promise((resolve, reject) => {
        axios.get('/index/project/projectChildrenList').then(res => {
            resolve(res.data.data)
        }).catch(err => {
            reject(err)
        })
    })
}

const addProjectChildren = async (params) => {
    return await new Promise((resolve, reject) => {
        axios.post('/index/project/addProjectChildren', params).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}

const addProjectLeader = async (params) => {
    return await new Promise((resolve, reject) => {
        axios.post('/index/project/linkProjectLeader', params).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}

const unLinkProject = async(params) => {
    return await new Promise((resolve, reject) => {
        axios.post('/index/project/unLinkProject', params).then(res => {
            resolve(res);
        }).catch(err => {
            reject(err);
        });
    });
}

const getProjectLeader = async () => {
    return await new Promise((resolve, reject) => {
        axios.get('/index/project/projectLeader').then(res => {
            resolve(res.data.data);
        }).catch(err => {
            reject(err);
        });
    });
}

const unLinkLeaderProject = async (params) => {
    return await new Promise((resolve, reject) => {
        axios.post('/index/project/unLinkLeaderProject', params).then(res => {
            resolve(res);
        }).catch(err => {
            reject(err);
        });
    });
}

export default {
    getProjectBaseInfo,
    saveProjectBaseInfo,
    getProjectChildrenList,
    addProjectChildren,
    addProjectLeader,
    unLinkProject,
    getProjectLeader,
    unLinkLeaderProject
}
